home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3965 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: newsgw.mentorg.com!news
  2. From: paulf@paulf.wv.mentorg.com (Paul Furnanz)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Vector of abstract classes using STL
  5. Date: 26 Jan 1996 16:38:45 -0800
  6. Organization: Mentor Graphics Corp. Wilsonville, OR
  7. Sender: paulf@paulf.wv.mentorg.com
  8. Message-ID: <vajivhyv5d6.fsf@paulf.wv.mentorg.com>
  9. References: <3103699A.79F8@ce.kth.se> <3103DF74.2C71@cs.rpi.edu>
  10. NNTP-Posting-Host: paulf.wv.mentorg.com
  11. In-reply-to: Bowden Wise's message of Mon, 22 Jan 1996 11:03:16 -0800
  12. X-Newsreader: Gnus v5.0.2
  13.  
  14. >>>>> "Bowden" == Bowden Wise <wiseb@cs.rpi.edu> writes:
  15.  
  16.  >> I think I have to use a vector<Shape*> but does the vector delete
  17.  >> the shape elements when the program finishes?
  18.  
  19.  Bowden> You are correct.  The STL does NOT delete the shape elements.  The
  20.  Bowden> STL takes care of deleting the elements in the container, but not
  21.  Bowden> what those pointers point to.  You can either delete the shapes
  22.  Bowden> yourself before the program terminates.  
  23.  
  24. You could just use ``vector<auto_ptr<Shape>>''.  When the vector
  25. destroys the auto_ptr<Shape>, then the pointed to object will be
  26. deleted.
  27. -- 
  28. --------
  29. Paul Furnanz                       Phone:  (503) 685-7000 (ext.1731) 
  30. Mentor Graphics Corporation        Email:  paul_furnanz@mentorg.com 
  31.